<?php
include('rootlogin.php');
//include('../incsession.php');
session_start();
$err=0;
if($_POST['submit']=="submit"){
	
	if($_POST['on_off']=='on' && $_POST['qurl']!=''){
		
		
		$query = "UPDATE system 
					SET qurl='".$_POST['qurl']."', 
				    	questionnaire=1";
		$result = mysql_query($query,$user_con);
	}
	else if($_POST['on_off']=='on' && $_POST['qurl']==''){
		$err=1;
	}
	else if($_POST['on_off']=='off'){
		
		
		//$query = "UPDATE system 
		//			SET qurl='".$_POST['qurl']."', 
		//		    	questionnaire=0";
		$query = "UPDATE system 
					SET questionnaire=0";
		$result = mysql_query($query,$user_con);	
	}
	
}
if($_POST['submit']=="back to index"){
	header("location: index.php");
}


?>

<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="framestyle.css" type="text/css" media="screen">
<style type="text/css">

</style>
</head>


<body>

<div id="wrapper">
<div id="title">Online Listening Comprehension Program</div>

<div id="main">
<hr/>
<div id="title2">CHANGE THE QUESTIONNAIRE</div>
<div id="title3">

</div>

<hr/>
<br><br>
<form method = POST action="questionnaire.php">
<?php


$query = "SELECT qurl,questionnaire FROM system";
$result = mysql_query($query,$user_con);
$row = mysql_fetch_array($result);
if($err==1){
	echo "<div id='error'>Error. Please fill in the questionaire URL.</div><br>";	
}
?>
<input type=radio name=on_off value=on <?php if($row['questionnaire']==1){echo "checked";} ?>>on
<input type=radio name=on_off value=off <?php if($row['questionnaire']==0){echo "checked";} ?>>off
<br><br>
<br>
<?php

if($row['questionnaire']==0)
	echo "previous questionnaire:";
else
	echo "current questionnaire:";
echo "<a href='".$row['qurl']."'>".$row['qurl']."</a>";
	
?>
<br><br>
<td align="right">questionnaire URL:<td><input class="area long" type="text" name="qurl">

<br><br>
<div class="btn_right"><input type="submit" name = "submit" value = "submit"></div><br>
<div class="btn_right"><input type="submit" name = "submit" value = "back to index"></div>
</form>
</div>
</div>
</body>

